package com.v2.k43;


import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * 测试@Bean是否可以没有@Component
 * 结论：@Component注解不能去掉，没有则会扫不到里面test方法（@Bean修饰）返回的对象
 */
public class TestBean {

	public static void main(String[] args) {

		AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class);

		System.out.println(applicationContext.getBean(Peoson.class)); //根据类型获得bean
		System.out.println(applicationContext.getBean("test11")); //根据方法名获得bean

	}


}
